package com.example.job_backend.controller;

import com.example.job_backend.model.EmploymentStatus;
import com.example.job_backend.model.R;
import com.example.job_backend.service.EmploymentStatusService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class EmploymentStatusController {
    @Resource
    private EmploymentStatusService employmentStatusService;

    @GetMapping("/employmentStatusWx")
    public R getEmploymentStatusByUsername(String username) {
        List<EmploymentStatus> list = employmentStatusService.getEmployStatusByUsername(username);
        return new R(200, "请求成功", list);
    }

    @GetMapping("/addEmploymentStatusWx")
    public R addEmploymentStatusWx(EmploymentStatus employmentStatus) {
        employmentStatusService.save(employmentStatus);
        return new R(200, "保存成功", null);
    }

    @GetMapping("/getEmployById/{id}")
    public R getEmployById(@PathVariable("id") Integer id) {
        EmploymentStatus employmentStatus = employmentStatusService.getById(id);
        return new R(200, "请求成功", employmentStatus);
    }

    @GetMapping("/updateEmploy")
    public R updateEmploy(EmploymentStatus employmentStatus) {
        employmentStatusService.updateById(employmentStatus);
        return new R(200, "更新成功", null);
    }

    @GetMapping("/deleteEmploy/{id}")
    public R delete(@PathVariable("id") Integer id) {
        employmentStatusService.removeById(id);
        return new R(200, "删除成功", null);
    }
}
